#include "N1Test.h"

//N1List* N1Tests::m_testList;
N1StaticVariable<N1List> m_testList(NULL);


bool N1Tests::addTest(const char *name, N1TestFunction function, 
                      const char* groups, const char* desc, N1Int32 OSs, N1Int32 retCode)
{
    m_testList->addHead( new N1Test(name, desc, OSs, function, retCode) );
    return true;
}

bool N1Tests::runAllTests()
{
    N1POSITION pos = m_testList->getHeadPosition( );
    while(pos) 
    {
        N1Object *obj = m_testList->getNext(pos);
        N1Test* test = dynamic_cast<N1Test*>(obj);
        if(test)
        {
            test->runTest();
        }
    }
    return true;
}

int  N1Tests::runTest(const char *test)
{
    N1POSITION pos = m_testList->getHeadPosition( );
    while(pos) 
    {
        N1Object *obj = m_testList->getNext(pos);
        N1Test* test = dynamic_cast<N1Test*>(obj);
        if(test)
        {
            return test->runTest();
        }
    }
    return -1;
}

